<extend name="Public/base"/>

<block name="body">
    <div class="page-bar">
        <ul class="page-breadcrumb">
            <li>
                <a href="{:U('Admin/Index/index')}">首页  </a>
                <i class="fa fa-circle"></i>
            </li>
            <li>
                <span>消息模板</span>
            </li>
        </ul>
        <div class="page-toolbar">
            <include file="Public/_addTo"/>
        </div>
    </div>

    <div class="main-title">
        <h2>
            <present name="data">[ {$data.title} ] 子</present>
            消息模板
        </h2>
    </div>

    <div class="with-padding">

        <form method="post" action="{:U('saveMessageEvent')}" class="auth-form">
            <table class="table table-bordered table-striped table-hover">
                <thead>
                <tr>
                    <th>事件</th>
                    <th>事件标识</th>
                    <th class="row-selected">
                        <input class="checkbox J_checkAll" type="checkbox" id="zhanneiAll" style="display: inline-block"><span>站内消息</span>
                    </th>
                    <th class="row-selected">
                        <input class="checkbox J_checkAll" type="checkbox" id="smsAll" style="display: inline-block"><span>短信</span>
                    </th>
                    <th class="row-selected">
                        <input class="checkbox J_checkAll" type="checkbox" id="emailAll" style="display: inline-block"><span>电子邮件</span>
                    </th>
                    <!--<th class="row-selected">
                        <input class="checkbox check-all" type="checkbox">微信公众号消息
                    </th>
                    <th class="row-selected">
                        <input class="checkbox check-all" type="checkbox">APP推送
                    </th>-->
                </tr>
                </thead>
                <tbody>
                <tr><td>动态&nbsp<a href="{:U('Message/addMessageEvent')}">添加模板</a></td></tr>
                <volist name="event" id="event">
                    <tr>
                        <td>{$event.title}&nbsp<a href="{:U('Message/editMessageTemplate', array('id' => $event['id']))}">编辑模板</a></td>
                        <td>{$event.name}</td>
                        <td data-role="zhannei"><input class="id row-selected" type="checkbox" name="zhannei[]" value="{$event.id}"
                            <eq name="event['zhannei']" value="1">checked</eq> ></td>
                        <td data-role="sms"><input class="sd row-selected" type="checkbox" name="sms[]" value="{$event.id}"
                            <eq name="event['sms']" value="1">checked</eq> ></td>
                        <td data-role="email"><input class="td row-selected" type="checkbox" name="email[]" value="{$event.id}"
                            <eq name="event['email']" value="1">checked</eq> ></td>
                    </tr>
                </volist>

                </tbody>
            </table>
            <button type="submit" class="btn submit-btn ajax-post" target-form="auth-form">保存设置</button>
        </form>
        <!-- 分页 -->
        <div class="page">

        </div>
    </div>
</block>

<block name="script">
    <script type="text/javascript">
        $(function(){
            $(".J_checkAll").click(function(){
                var name = this.id.substring(0,this.id.length-3);
                if(this.checked){
                    $("[data-role="+name+"]").find("input[name='"+name+"[]']").each(function(){this.checked=true;});
                }else{
                    $("[data-role="+name+"]").find("input[name='"+name+"[]']").each(function(){this.checked=false;});
                }
            });
        });
    </script>
</block>